<template>
    <div>
        <div style="margin-bottom: 5px;" v-if="this.user.roleId!=2">
            <el-input v-model="no" style="width: 200px;" placeholder="请输入餐馆名!" suffix-icon="el-icon-search"
                      @keyup.entry.native="loadPost1"
            ></el-input>
            <el-button style="margin-left: 5px;" type="primary" @click="loadPost1">查询</el-button>
            <el-button type="success" @click="resetparam1">重置</el-button>
        </div>
        <div style="margin-bottom: 5px;" v-if="this.user.roleId==2">
            <el-input v-model="name" style="width: 200px;" placeholder="请输入菜名!" suffix-icon="el-icon-search"
                      @keyup.entry.native="loadPost"
            ></el-input>
            <el-input v-model="menutype" style="width: 200px;" placeholder="请输入菜品类型!" suffix-icon="el-icon-search"
                      @keyup.entry.native="loadPost"
            ></el-input>
            <el-button style="margin-left: 5px;" type="primary" @click="loadPost">查询</el-button>
            <el-button type="success" @click="resetparam">重置</el-button>
            <el-button style="margin-left: 5px;" type="primary" @click="add">新增</el-button>
        </div>

        <el-table :data="tableData"
                  :header-cell-style="{background: '#f2f5fc', color: '#555'}"
                  border

        >
            <el-table-column prop="id" label="ID" width="60">
            </el-table-column>
            <el-table-column prop="no" label="餐馆账号" width="140">
            </el-table-column>
            <el-table-column prop="name" label="菜名" width="140">
            </el-table-column>
            <el-table-column prop="price" label="价格" width="80">
                <template slot-scope="scope">
                    <span>￥{{scope.row.price}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="menutype" label="菜品类型" width="180">
            </el-table-column>
            <el-table-column prop="menutxt" label="菜品简介" width="180">
            </el-table-column>
            <el-table-column prop="imgurl" label="菜品图片" width="180">
                <template slot-scope="scope">
                    <img :src="'http://localhost:9099'+scope.row.imgurl" alt="" style="width: 100px;height: 80px;">
                </template>
            </el-table-column>
            <el-table-column prop="operate" label="操作" v-if="this.user.roleId==2">
                <template slot-scope="scope">
                    <el-button size="small" type="success" @click="mod(scope.row)">编辑</el-button>
                    <el-popconfirm
                            title="确定删除吗?"
                            @confirm="del(scope.row.id)"
                            style="margin-left: 5px"
                    >

                        <el-button slot="reference" size="small" type="danger">删除</el-button>
                    </el-popconfirm>

                </template>
            </el-table-column>
        </el-table>

        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="pageNum"
                :page-sizes="[2,4,8,16]"
                :page-size="pageSize"
                layout="total,sizes,prev,pager,next,jumper"
                :total="total"
        >


        </el-pagination>
        <el-dialog
                title="添加信息"
                :visible.sync="centerDialogVisible"
                width="40%"
                style="left: 60px;"
        >


            <el-form ref="form"  :model="form" label-width="80px">
                <!--                <el-form-item label="餐馆名" prop="no">-->
                <!--                    <el-col :span="14">-->
                <!--                        <el-input v-model="form.no"></el-input>-->

                <!--                    </el-col>-->
                <!--                </el-form-item>-->
                <el-form-item label="菜名" prop="name">
                    <el-col :span="14">
                        <el-input v-model="form.name"></el-input>

                    </el-col>
                </el-form-item>
                <el-form-item label="价格" prop="price">
                    <el-col :span="14">
                        <el-input v-model="form.price"></el-input>

                    </el-col>
                </el-form-item>
                <el-form-item label="菜品类型" prop="menutype">
                    <el-col :span="14">
                        <el-input v-model="form.menutype"></el-input>

                    </el-col>
                </el-form-item>
                <el-form-item label="菜品介绍" prop="menutxt">
                    <el-col :span="14">
                        <el-input type="textarea" v-model="form.menutxt"></el-input>

                    </el-col>
                </el-form-item>
                <!--                <el-form-item label="菜品图片路径" prop="imgurl">-->
                <!--                    <el-col :span="14">-->
                <!--                        <el-input  v-model="form.imgurl"></el-input>-->

                <!--                    </el-col>-->
                <!--                </el-form-item>-->
                <el-form-item label="菜品图片">
                    <el-upload
                            class="avatar-uploader"
                            action="http://localhost:9099/menulist/upload/"
                            :show-file-list="false"
                            :on-success="handleAvatarSuccess"
                            :before-upload="beforeAvatarUpload">
                        <img v-if="imageUrl" :src="imageUrl" class="avatar">
                        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                    </el-upload>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                        <el-button @click="centerDialogVisible=false">取消</el-button>
                        <el-button type="primary" @click="save">确定</el-button>


                    </span>
        </el-dialog>

    </div>
</template>

<script>
    export default {
        name: "room-tipMange"
    }
</script>

<style scoped>

</style>